@model AddLocalizationViewModel
@using Orchard.Localization.ViewModels;
@{
    dynamic content = Model.Content;
    content.Zones.Content.Add(New.Partial(TemplateName: "CultureSelection", Model: Model), "0");

    Layout.Title = T("Translate Content").ToString();
}

@using (Html.BeginFormAntiForgeryPost()) {
    @Html.ValidationSummary()
    @Display(Model.Content)
}
@using (Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
    (function ($) {
        // grab the slug input
        var slug = $("#Routable_Slug");
        if (slug) {
            // grab the current culture
            var culture = $("#SelectedCulture");
            var currentCulture = culture.val();
            // when the culture is changed update the slug
            culture.change(function () {
                var slugValue = slug.val();
                var newCulture = $(this).val();
                if (slugValue && slugValue.match(currentCulture + "$")) {
                    slug.val(slugValue.replace(new RegExp(currentCulture + "$", "i"), newCulture));
                    currentCulture = newCulture;
                }
            });
        }
    })(jQuery);
//]]>
</script>
}